package com.wise.file.server.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 全局配置
 */
@Configuration
@ComponentScan(basePackages = "com.wise.file.server")
public class FileServerConfig implements WebMvcConfigurer {//extends WebMvcConfigurationSupport {

    /**
     * 跨域路径映射
     * @param registry
     */
    /*@Override
    protected void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*");
    }*/

    /**
     * 不经过controller 硬盘映射文件
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/myimgs/**").addResourceLocations("file:E:/myimgs/");
        registry.addResourceHandler("/myre/**").addResourceLocations("file:E:/myimgs/myre");
    }
}
